﻿@using Webdiyer.WebControls.Mvc
@model Webdiyer.WebControls.Mvc.PagedList<WeChatService.Models.efmodel.SendAll>
@{
    ViewBag.Title = "Index";
}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed');
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="/welcome/index">首页</a>
            </li>
            <li class="active">群发消息</li>
        </ul><!-- .breadcrumb -->

    </div>
    
    <div class="page-content">
        <div class="page-header">
            <h1>
                群发消息
            </h1>
        </div><!-- /.page-header -->

        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="alert alert-block alert-success">
                    <button type="button" class="close" data-dismiss="alert">
                        <i class="icon-remove"></i>
                    </button>
                    注意：<br />用户每月只能接收4条群发消息！<br />
                    微信公众平台严禁恶意营销以及诱导分享朋友圈，严禁发布色情低俗、暴力血腥、政治谣言等各类违反法律法规及相关政策规定的信息！<br />
                </div>
                <div>
                    <a id="a_add_autoresp" class="btn btn-success" href="#modal-autoresp-event" data-toggle="modal">
                        <i class="icon-beaker align-top bigger-110"></i>
                        群发消息
                    </a>
                    <br/><br/>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th class="center">
                                            <label>
                                                <span class="lbl"></span>
                                            </label>
                                        </th>
                                        <th>素材编号</th>
                                        <th>提交状态</th>
                                        <th>发送成功数量</th>
                                        <th>发送失败数量</th>
                                        <th>发送时间</th>
                                    </tr>
                                </thead>

                                <tbody>
                                    @{
                                        if (Model != null && Model.Any())
                                        {
                                            foreach (var item in Model)
                                            {
                                                <tr id="data-item-@item.ID">
                                                    <td class="center">@item.ID</td>
                                                    <td>@item.MsgIDs</td>
                                                    <td>@item.ErrorMsg</td>
                                                    <td>@item.SuccessCount</td>
                                                    <td>@item.FaildCount</td>
                                                    <td>@item.Createtime</td>
                                                </tr>
                                            }
                                        }
                                    }
                                    

                                </tbody>
                            </table>
                        </div><!-- /.table-responsive -->
                        
                        <div style="height: 100px; line-height: 50px; clear: both; " align="center">
                            @Html.Pager(Model,
                                        new PagerOptions
                                        {
                                            CssClass = "page_a",
                                            PageIndexParameterName = "pageIndex",
                                            ShowPageIndexBox = false,
                                            PageIndexBoxType = PageIndexBoxType.DropDownList,
                                            ShowGoButton = false,
                                        })
                        </div>

                        
                        <input type="hidden" id="edit_item_id"/>
                    </div><!-- /span -->
                </div><!-- /row -->		
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
</div>


<!--要弹出的群发编辑框-->
<div id="modal-autoresp-event" class="modal hide" style="display: none;" aria-hidden="true">
    <div class="modal-header">
        <button class="close" data-dismiss="modal" type="button">
            ×</button>
        <h3>群发消息</h3>
    </div>
    <form id="modal-autoresp-form" action="/AutoResp/Add" method="POST">
    <div class="modal-body">
        <span>类型 &nbsp;&nbsp;</span>
            <select id="autoresp_type" class="input-xlarge" name="type" onchange="clearMsgInput();">
                <option value="1" selected="selected">文字消息</option>
                <option value="3">图文消息</option>
                <option value="4">多图文消息</option>
            </select>
        <br /><br />
        <span>消息 &nbsp;&nbsp;</span>
            <input id="autoresp_msgid" name="msgid" class="input-xlarge" type="text" value="" readonly="readonly"/>
            <a id="a_sel_msg" class="btn btn-success btn-sm" style="padding-top: 5px;padding-bottom: 0px;">
                        <i class="icon-beaker align-top bigger-110"></i>
                        选择素材
                    </a>
        <br /><br />
        <br /><br />
    </div>
    <div class="modal-footer">
        <a class="btn" data-dismiss="modal" href="#" onclick="clearMsgInput();">取消</a>
        <a id="autoresp-event-submit" class="btn btn-primary" href="#">确定</a>
    </div>
    </form>
</div>
<!---->



<!-- JS -->
<script src="@Url.Content("~/Content/layer/layer.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    jQuery(function ($) {
        $("#menu-sendmsgall-li").addClass("active");

        //群发提交
        $("#autoresp-event-submit").on(ace.click_event, function () {
            var msgid = $("#autoresp_msgid").val();
            if (msgid == "") {
                showError("消息不能为空", "");
            } else {
                $("#autoresp_event").attr("disabled", false);
                $("#modal-autoresp-form").submit();
            }
        });
        $("#modal-autoresp-form").ajaxForm({
            success: function (result) {
                $("#autoresp_event").attr("disabled", true);
                if (result.rel == 1) {
                    showTipAndReload(result.msg, "");
                } else {
                    showError(result.msg, "");
                }
            }
        });


        $("#a_sel_msg").on(ace.click_event, function () {
            var type = $("#autoresp_type").val();
            var msg = "";
            if (type == "1") { msg = "(文字消息，一项，以最后一次选择为准)"; }
            if (type == "3") { msg = "(图文消息，一项，以最后一次选择为准)"; }
            if (type == "2") { msg = "(音乐消息，一项，以最后一次选择为准)"; }
            if (type == "4") { msg = "(多图文消息，最多五项，排序以选择顺序为准)"; }
            $.layer({
                type: 2,
                shade: [0],
                fix: false,
                title: msg + '选完关闭本层',
                maxmin: true,
                iframe: { src: '/Message/Simple?type=' + type },
                area: ['800px', '440px']
            });
        });

        clearMsgInput();
    });

    function clearMsgInput() {
        $("#autoresp_msgid").val('');
    }

</script>


